package com.test;


import com.model.user;
import com.service.userService;
import com.web.action.userAction;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class lesson3 {

    @Test
    public void test1() throws Exception{

        ApplicationContext context = new ClassPathXmlApplicationContext("bean2.xml");

//        userService service = (userService) context.getBean("userService");
//
//        user user1 = new user();
//        user1.setUserName("ahah");
//        user1.setPassword("sshsh");
//        service.add(user1);

        userService userService = (com.service.userService) context.getBean("userService");

        user user = new user();
        user.setUserName("ahaah");
        user.setPassword("aaa");

        userService.add(user);
    }

    @Test
    public void test2() throws Exception{

        ApplicationContext context = new ClassPathXmlApplicationContext("bean3.xml");

//        userService service = (userService) context.getBean("userService");
//
//        user user1 = new user();
//        user1.setUserName("ahah");
//        user1.setPassword("sshsh");
//        service.add(user1);

        userAction userAction = (userAction) context.getBean("userAction");
        userAction action = context.getBean(userAction.class);
        user user = new user();
        user.setUserName("ahaah");
        user.setPassword("aaa");

        userAction.save(user);

    }
}
